﻿using System;
using System.Diagnostics.Contracts;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.OfficeArt
{
    internal class OfficeArtFSPGR: OfficeArtRecord
    {
        private int xLeft;
        private int xRight;
        private int yBottom;
        private int yTop;

        public override RecType RecordType
        {
            get { return RecType.OfficeArtFSPGR; }
        }

        protected override void ReadNoHeader(OfficeArtReadContext context)
        {
            Contract.Assert(rhrecVer == 1);
            Contract.Assert(rhrecInstance == 0);
            Contract.Assert(rhrecType == (RecType) 0xF009);
            Contract.Assert(rhrecLen == 0x00000010);
            xLeft = context.ReadInt32();
            yTop = context.ReadInt32();
            xRight = context.ReadInt32();
            yBottom = context.ReadInt32();
        }

        protected override byte Version
        {
            get { return 1; }
        }

        protected override int ByteLength
        {
            get { return 16; }
        }


        protected override void WriteNoHeader(OfficeArtWriteContext context)
        {
            Contract.Assert(rhrecVer == 1);
            Contract.Assert(rhrecInstance == 0);
            Contract.Assert(rhrecType == (RecType)0xF009);
            Contract.Assert(rhrecLen == 0x00000010);
            context.Write(xLeft);
            context.Write(yTop);
            context.Write(xRight);
            context.Write(yBottom);
        }

        protected override void PrepareHeader(ref OfficeArtRecordHeader rh)
        {
            rh.recVer = 1;
            rh.recLen = 0x00000010;
        }
    }
}